package reply

// UnknownErrReply
// @Description: 未知错误
type UnknownErrReply struct {
}

var unKnownErrBytes = []byte("-Err unknown\r\n")

func (u *UnknownErrReply) Error() string {
	return "Err known"
}

func (u *UnknownErrReply) ToBytes() []byte {
	return unKnownErrBytes
}

// ArgNumErrReply
// @Description: 参数数量错误
type ArgNumErrReply struct {
	Cmd string
}

var theArgNumErrReply = new(ArgNumErrReply)

func (a *ArgNumErrReply) Error() string {
	return "Err argNum error"
}

func (a *ArgNumErrReply) ToBytes() []byte {
	return []byte("-ERR wrong number of arguments for '" + a.Cmd + "' command\\r\\n")
}

func NewTheArgNumErrReply() *ArgNumErrReply {
	return theArgNumErrReply
}

// SyntaxErrReply
// @Description: 语法错误
type SyntaxErrReply struct {
}

var syntaxErrReplyBytes = []byte("-Err syntax error\r\n")
var theSyntaxErrReply = new(SyntaxErrReply)

func (s *SyntaxErrReply) Error() string {
	return "Err syntax error"
}

func (s *SyntaxErrReply) ToBytes() []byte {
	return syntaxErrReplyBytes
}

func NewSyntaxErrReply() *SyntaxErrReply {
	return theSyntaxErrReply
}

// WrongTypeErrReply
// @Description: 错误类型回复
type WrongTypeErrReply struct {
}

var wrongTypeErrReplyBytes = []byte("-WRONGTYPE operation against a key holding the wrong kind of value")
var theWrongTypeErrReply = new(WrongTypeErrReply)

func (w *WrongTypeErrReply) Error() string {
	return "WRONGTYPE operation against a key holding the wrong keind of value"
}

func (w *WrongTypeErrReply) ToBytes() []byte {
	return wrongTypeErrReplyBytes
}
func NewWrongTypeErrReply() *WrongTypeErrReply {
	return theWrongTypeErrReply
}

// StandardErrReply
// @Description:
type StandardErrReply struct {
	Status string
}

func (s *StandardErrReply) Error() string {
	return s.Status
}

func (s *StandardErrReply) ToBytes() []byte {
	return []byte("-" + s.Status + CRLF)
}

func NewStadardErrReply(status string) *StandardErrReply {
	return &StandardErrReply{Status: status}
}
